package com.mxw.job;

import com.mxw.service.AWebSpiderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ResourceJob {
    private static final Logger logger = LoggerFactory.getLogger(ResourceJob.class);

    @Autowired
    private AWebSpiderService spiderService;

    /**
     * 每四天执行一次爬虫任务
     * cron表达式：秒 分 时 日 月 周
     */
    @Scheduled(cron = "0 0 5 */4 * ?")
    public void spiderJob() {
        try {
            spiderService.spider(-1);
        } catch (Exception e) {
            logger.error("创建草稿定时任务执行失败", e);
        }
    }
}
